#pragma once

#include "LinkAction.h"

#include "Association.h"
#include "InputPin.h"
#include "LinkEndData.h"

namespace uml {

LinkAction::LinkAction(const QString& umlType)
    : Action(umlType) {}

void LinkAction::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    Action::fromJson(json, errorList);
    JsonSerializable::fromJsonArray(endDatas_, "endDatas", json, errorList);
    JsonSerializable::fromJsonArray(inputValues_, "inputValues", json, errorList);
}

void LinkAction::toJson(QJsonObject& json) {
    Action::toJson(json);
    JsonSerializable::toJsonArray(endDatas_, "endDatas", json);
    JsonSerializable::toJsonArray(inputValues_, "inputValues", json);
}

/// <summary>
/// association
    /// Returns the Association acted on by this LinkAction.
/// </summary>
    /// <code>
    /// result = (endData->asSequence()->first().end.association)
    /// </code>
shared_ptr<Association> LinkAction::association() const
{
    return nullptr;
}

/// <summary>
/// endDatas getter
/// The LinkEndData identifying the values on the ends of the links acting on by
/// this LinkAction.
/// </summary>
vector<shared_ptr<LinkEndData>>& LinkAction::endDatas() {
    return endDatas_;
}

/// <summary>
/// inputValues getter
/// InputPins used by the LinkEndData of the LinkAction.
/// </summary>
vector<shared_ptr<InputPin>>& LinkAction::inputValues() {
    return inputValues_;
}

} // namespace uml
